package com.wang.exception_homework.hw3;

public class Demo {
    public static void main(String[] args) {
        double a = 10;
        double b = 0;
        try {
            double result = divide(a,b);
            System.out.println("商为：" + result);
        } catch (ArithmeticException e) {
            System.out.println("发生错误：" + e.getMessage());
        }
    }

    public static double divide(double a,double b) throws ArithmeticException{
        if (b == 0){
            throw new ArithmeticException("除数不能为零");
        }
        return a / b;
    }
}
